# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# GNU Makefile based on shared rules provided by the Native Client SDK.
# See README.Makefiles for more details.

VALID_TOOLCHAINS := pnacl glibc clang-newlib linux

NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..)

TARGET = ffmpeg_decoder

FFMPEG_INC_DIR = $NACL_SDK_ROOT/toolchain/linux_pnacl/le32-nacl/usr/include	

INCLUDES = -I$(INC_DIR) -I$(FFMPEG_INC_DIR)

include $(NACL_SDK_ROOT)/tools/common.mk
DEPS = ppapi_simple
LIBS = ppapi_gles2 ppapi_cpp ppapi pthread  avformat avcodec  swresample avutil avdevice avfilter x264

CFLAGS = -Wall -O2 -Wno-unused-variable -pthread  -lavformat -lavcodec  -lswresample -lavutil -lavdevice -lavfilter -lx264

SOURCES = ffmpeg_decoder.cc

# Build rules generated by macros from common.mk:
$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep))))
$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))

# The PNaCl workflow uses both an unstripped and finalized/stripped binary.
# On NaCl, only produce a stripped binary for Release configs (not Debug).
ifneq (,$(or $(findstring pnacl,$(TOOLCHAIN)),$(findstring Release,$(CONFIG))))
$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
else
$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
endif

$(eval $(call NMF_RULE,$(TARGET),))
